<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>签约网</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="../css/baguetteBox.css"/>
    <link rel="stylesheet" type="text/css" href="../css/lawyer.css" />
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../script/swiper.min.js"></script>
    <script type="text/javascript" src="../script/baguetteBox.js"></script>
    <script type="text/javascript" src="../script/highlight.min.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/lawyer.js"></script>
</head>
<body>
<div id="secHeader">
  <header class="header">
      <a href="javascript:void(0);" onclick="api.closeWin()" class="back_btn"><img src="../image/head-fanhui.png" alt=""></a>
      <h2>合同详情</h2>
      <a href="tel:12345678910" class="tel_btn"><img src="../image/tel.png" alt=""></a>
  </header>
</div>
<section class="contract_img">
    <div class="swiper-container baguetteBoxOne">
        <ul class="swiper-wrapper" id='con'>

        </ul>
    </div>
    <div class="swiper-pagination"></div>
    <script>
        baguetteBox.run('.baguetteBoxOne');
        var mySwiper = new Swiper('.swiper-container', {
            autoplay: 5000,//可选选项，自动滑动
            slidesPerView: 2.8,
            spaceBetween: 20,
            pagination : '.contract_img .swiper-pagination',
        })
    </script>
</section>

<section class="contract_detail">
    <div class="contract_name">
        <h6 id='name'>房屋租赁合同</h6>
        <p id='money'>￥52.99/份</p>
    </div>
    <div class="contract_name">

        <p id='content' style="color:#000"></p>
    </div>
    <h2 class="service_title">服务流程</h2>
    <div class="flow_list">
        <ul>
            <li><em>1</em><p>选择合同</p></li>
            <li><em>2</em><p>支付购买</p></li>
            <li><em>3</em><p>下载合同</p></li>
            <li><em>4</em><p>打开或发送</p></li>
        </ul>
    </div>
    <h2 class="service_title">服务说明</h2>
    <div class="notes">
        <p>
            1、因合同模板特殊性，一旦购买成功，视为已享受服务，不予退款；<br>
            2、如遇合同下载，打开等问题，请联系平台客服；<br>
            3、注册下载APP即可免费下载3次，每推广一个用户注册或者下载APP就可以获得一个下载码，免费下载1次。

        </p>
    </div>
</section>
<!--<div class="pay-links">
    <p><span   onclick="free_contract()">会员免费</span></p>
    <a href="javascript:void (0);" onclick="buy_contract()" class="link_btn" id="paymoney"></a>
</div>-->

<div class="pay-links" id="pay1">
    <p style="background: #fff"><span  onclick="free_contract()">会员免费</span></p>
    <a href="javascript:void (0);" onclick="buy_contract()" class="link_btn" id='paymoney'>确认支付： ￥52.99</a>
</div>
<div class="pay-links" id="pay2" style="display: none;">
    <a href="javascript:void (0);" style="width: 100%!important;" onclick="" class="link_btn" id='download'>下载合同</a>
</div>



</body>

<script>
    var para
    var money=0;
    var htnum;
    var fileUrl;
    apiready = function () {
      $api.fixStatusBar( $api.dom('#secHeader') );
      api.setStatusBarStyle({
          style: 'light'
      });




        para=api.pageParam;

        $('.tel_btn').attr('href','tel:'+webphone);

        var my=para.my;
        if(my==1){
            $('#pay1').hide();
            $('#pay2').show();
        }else{

        }

        $("#download").click(function(){

            //alert(fileUrl+','+fileName);
            var downloadManager = api.require('downloadManager');

            downloadManager.openManagerView({
                title: '下载管理'
            }, function(rett, err) {
                if (rett) {
                  //  alert(JSON.stringify(rett));

                    downloadManager.enqueue({
                        url: webSiteUrl+fileUrl
                      }, function(ret, err) {
                        if (ret) {
                          downloadManager.openDownloadedFile({
                                  id: ret.id
                              }, function(ret, err) {

                              });
                        } else {
                        //  console.log(2)
                            //alert(JSON.stringify(err));
                        }
                    });
                }
            });

        });


        toDoRequest()
    };

    function toDoRequest(){
        var p= {id:para.id};

        api.ajax({
            url: webSiteUrl+'/app/public/htdetail',
            method: 'post',
            data: {
                values: p
            }
        }, function(ret, err) {
            api.hideProgress();

            if(ret.code==200){

                html = "";
                var tj=ret.data;
                $('#name').html(tj.name);
                $('#content').html(tj.content);
                $('#money').html('￥'+tj.money+'/份');
                $('#paymoney').html('确认支付： ￥'+tj.money);
                money=tj.money

                var tj=ret.data;

                if(tj.num >0){

for(var i=0;i<tj.icons.length;i++){
    //html+=' <li class="swiper-slide"><img src="'+tj.icons[i]+'" alt=""></li>';
    html+=' <li class="swiper-slide"><a href="'+webSiteUrl+tj.icons[i]+'" data-caption="'+(i+1)+'" style="width:100%"><img src="'+webSiteUrl+tj.icons[i]+'" alt=""></a></li>';

}
                }
                //alert(tj.file);
                fileUrl = tj.file;
                $('#con').html(html);
                baguetteBox.run('.baguetteBoxOne');
                var mySwiper = new Swiper('.swiper-container', {
                    autoplay: 5000,//可选选项，自动滑动
                    slidesPerView: 2.8,
                    spaceBetween: 20,
                    pagination : '.contract_img .swiper-pagination',
                })

            }else{
                if(page==1){
                    $('#con').html(kong);
                }

            }
            user()
        });

    }

    function buy_contract(){
        if(!loginCheck()){
          return false;
        }
        api.openWin({
            name: 'buy_contract',
            url: './buy_contract.html',
            reload:true,
            pageParam: {
                money:money,
                id:para.id
            }
        });

    }
    function free_contract() {
        if(vip>0){
            if(htnum==0){
                alert('免费次数已用完，请支付购买');return;
            }
            var p={token:token,id:para.id,type:14}
            api.ajax({
                url: webSiteUrl+'/app/user/freeorder',
                method: 'post',
                data: {
                    values: p
                }
            }, function(ret, err) {


                if(ret.code == 200){
                    var orderno=ret.msg
                    aaplay('personal_myContract')

                }else{
                    alert(ret.msg);return false;

                }

            });

        }else{
            alert('您还未成为签约网的会员，快去成为会员吧 ！');
            aaplay('service_package')

        }
    }
    function user() {
        var p={token:token,infock:2}
         api.ajax({
                url: webSiteUrl+'/app/user/user',
                method: 'post',
                data: {
                    values: p
                }
            }, function(ret, err) {

            if (ret.code == 200) {

                var tj = ret.data;
                htnum=tj.htnum
            }
        })
    }
</script>
</html>
